import { currentTime, sendChatuiMessage, handleChatuiMessage } from '@/common/tools'
import GuessAsking from '@/components/GuessAsking' // 猜你想问
import DataBotCard from '@/components/DataBotCard' // 表格线图
import store from '@/store'
export const config = {
	lang: 'zh-CN',
	navbar: {
		title: '咨询助理'
	},
	robot: {
		avatar:
			''
	},
	avatarWhiteList: ['knowledge', 'recommend', 'guess-think', 'databot-card'],
	messages: [
		{
			type: 'system',
			content: {
				text: '智能助理进入对话，为您服务'
			}
		},
		{
			type: 'system',
			content: {
				text: currentTime
			}
		},
		{
			type: 'text',
			content: {
				text: '您好，很高兴为您服务！'
			}
		},
		{
			type: 'card',
			content: {
				code: 'guess-think',
				data: {
					list: [
						{
							text: '近一年江苏省贵烟的系统外销售量'
						},
						{
							text: '今年11月份黄鹤楼系统内购进量'
						},
						{
							text: '今年11月份黄鹤楼系统外购进量'
						},
						{
							text: '11月份河北省同期系统内购进量'
						}
					]
				}
			}
		}
	],
	// 输入框占位符
	placeholder: '输入任何您咨询的问题'
}
export const components = {
	'guess-think': GuessAsking,
	'databot-card': DataBotCard
}
export default function useConfig(dispatchCallback) {
	const requests = {
		send: function (message) {
			const { chat: chatValue } = store.getState()
			return sendChatuiMessage(message, chatValue, dispatchCallback)
		}
	}
	const handlers = {
		parseResponse: function (message, requestType) {
			return handleChatuiMessage(message, requestType, dispatchCallback)
		}
	}
	return {
		config,
		components,
		requests,
		handlers
	}
}
